export function getSessionStorage(key: string) {
  let data, obj;
  try {
    obj = sessionStorage.getItem(key);
    if (typeof obj === "string") {
      data = JSON.parse(obj);
    } else {
      data = obj;
    }
  } catch (e) {
    data = obj;
  }
  return data;
}

export function setSessionStorage(name: string, obj: any) {
  if (typeof obj === "object") {
    obj = JSON.stringify(obj);
  }
  sessionStorage.setItem(name, obj);
}
export function getLocalStorage(key: string) {
  let data, obj;
  try {
    obj = localStorage.getItem(key);
    if (typeof obj === "string") {
      data = JSON.parse(obj);
    } else {
      data = obj;
    }
  } catch (e) {
    data = obj;
  }
  return data;
}
export function setLocalStorage(name: string, obj: any) {
  if (typeof obj === "object") {
    obj = JSON.stringify(obj);
  }
  localStorage.setItem(name, obj);
}
